{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from scipy.stats import mode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [],
   "source": [
    "pred1 = pd.read_excel(\"ml_prob.xlsx\", index_col=None)\n",
    "pred2 = np.argmax(np.load('fastai_prob.npy'), axis=1)\n",
    "pred4 = np.argmax(np.load('model_xlnet_base_prob.npy'), axis=1)\n",
    "pred5 = np.argmax(np.load('model_xlnet_large_prob.npy'), axis=1)\n",
    "pred6 = np.argmax(np.load('model_bert_base_prob.npy'), axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [],
   "source": [
    "final_ensemble = mode((pred1['SECTION'], pred2,\n",
    "                       pred4, pred5, pred6))[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1    1188\n",
      "2     824\n",
      "0     418\n",
      "3     318\n",
      "Name: SECTION, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "submission = pd.DataFrame()\n",
    "submission['SECTION'] = final_ensemble\n",
    "submission.to_excel(\"ensemble_v25.xlsx\", index=None)\n",
    "print(submission['SECTION'].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
